package com.choichumgming.rentcat.web.controller;

import com.choichumgming.rentcat.common.api.CommonResult;
import com.choichumgming.rentcat.dto.OrderReturnParam;
import com.choichumgming.rentcat.service.OmsOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单管理Controller
 */

@RestController
@Api(tags = "OmsOrderController",description = "订单管理")
@RequestMapping("/")
public class OmsOrderController {

    @Autowired
    OmsOrderService omsOrderService;

    @ApiOperation("查看不同状态的订单")
    @RequestMapping(value = "",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult orderStatuslist(){
        return CommonResult.success(null);
    }

    //    需要订单完成后才能显示删除记录 订单状态：0->待付款；1->待发货；2->已发货；3->已完成；4->已关闭；5->无效订单
    @ApiOperation("删除订单记录")
    @RequestMapping(value = "/delete/{orderId}",method = RequestMethod.GET)
    @ResponseBody
    public CommonResult deleteOrder(@PathVariable("orderId") Long orderId){

        return CommonResult.success(null);
    }


    @ApiOperation("查看订单详情")
    @RequestMapping(value = "/item/{orderId}",method = RequestMethod.GET)
    @ResponseBody
    public CommonResult getOrderdetail(@PathVariable("orderId") Long orderId){
        OrderReturnParam orderReturnParam = omsOrderService.getitem(orderId);
        return CommonResult.success(orderReturnParam);
    }


    @ApiOperation("更新订单状态")
    @RequestMapping(value = "/update/status/{orderId}",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult updateOrderStatus(@PathVariable("orderId")Long orderId, @RequestBody int status) {
        omsOrderService.updateOrderStatus(orderId, status);
        return CommonResult.success("成功更新");
    }


}
